<?php

// Start of PECL pthreads 2.0.4

/**
*       线程的默认选项。线程开始的时候，pthreads 扩展会将环境复制到线程上下文中。      
*/
define('PTHREADS_INHERIT_ALL', 1118481);

/**
*       新线程开始时，不继承任何内容。      
*/
define('PTHREADS_INHERIT_NONE', 0);

/**
*       新线程开始时，仅继承 INI 配置。      
*/
define('PTHREADS_INHERIT_INI', 1);

/**
*       新线程开始时，继承用户定义的常量。      
*/
define('PTHREADS_INHERIT_CONSTANTS', 16);

/**
*       新线程开始时，继承用户定义的类。      
*/
define('PTHREADS_INHERIT_CLASSES', 4096);

/**
*       新线程开始时，继承用户定义的函数。      
*/
define('PTHREADS_INHERIT_FUNCTIONS', 256);

/**
*       新线程开始时，继承包含文件。      
*/
define('PTHREADS_INHERIT_INCLUDES', 65536);

/**
*       新线程开始时，继承所有的注释。      
*/
define('PTHREADS_INHERIT_COMMENTS', 1048576);

/**
*       允许新线程向标准输出发送头信息（通常情况下是被禁止的）。      
*/
define('PTHREADS_ALLOW_HEADERS', 16777216);

/**
*<div id="class.pool" class="reference">   <h1 class="title">Pool 类</h1>     <div class="partintro"><p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p>     <div class="section" id="pool.intro">    <h2 class="title">简介</h2>    <p class="para">     Pool 对象是多个 Worker 对象的容器，同时也是它们的控制器。    </p>    <p class="para">     线程池是对 Worker 功能的高层抽象，包括按照 pthreads 需要的方式来管理应用的功能。    </p>   </div>     <div class="section" id="pool.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Pool</strong>      </span>      {</div>      <div class="classsynopsisinfo classsynopsisinfo_comment">// 属性 </div>     <div class="fieldsynopsis">      <span class="modifier">protected</span>       <var class="varname"><a href="http://php.net/manual/zh/class.pool.php#pool.props.size">$<var class="varname">size</var></a></var>     ;</div>      <div class="fieldsynopsis">      <span class="modifier">protected</span>       <var class="varname"><a href="http://php.net/manual/zh/class.pool.php#pool.props.class">$<var class="varname">class</var></a></var>     ;</div>      <div class="fieldsynopsis">      <span class="modifier">protected</span>       <var class="varname"><a href="http://php.net/manual/zh/class.pool.php#pool.props.workers">$<var class="varname">workers</var></a></var>     ;</div>      <div class="fieldsynopsis">      <span class="modifier">protected</span>       <var class="varname"><a href="http://php.net/manual/zh/class.pool.php#pool.props.ctor">$<var class="varname">ctor</var></a></var>     ;</div>      <div class="fieldsynopsis">      <span class="modifier">protected</span>       <var class="varname"><a href="http://php.net/manual/zh/class.pool.php#pool.props.last">$<var class="varname">last</var></a></var>     ;</div>       <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.collect.php" class="methodname" style="color:#CC7832">collect</a></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.types.callable.php" class="type Callable" style="color:#EAB766">Callable</a></span> <span class="parameter" style="color:#2EACF9">$collector</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">Pool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.construct.php" class="methodname" style="color:#CC7832">__construct</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">string</span> <span class="parameter" style="color:#2EACF9">$class</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">array</span> <span class="parameter" style="color:#2EACF9">$ctor</span></span>   ]] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.resize.php" class="methodname" style="color:#CC7832">resize</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.shutdown.php" class="methodname" style="color:#CC7832">shutdown</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.submit.php" class="methodname" style="color:#CC7832">submit</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">$task</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/pool.submitTo.php" class="methodname" style="color:#CC7832">submitTo</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$worker</span></span>    , <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">$task</span></span>    )</div>     }</div>     </div>     <div class="section" id="pool.props">    <h2 class="title">属性</h2>    <dl>            <dt id="pool.props.size"><var class="varname"><var class="varname">size</var></var></dt>       <dd>        <p class="para">Pool 对象可容纳的 Worker 对象的最大数量</p>      </dd>                 <dt id="pool.props.class"><var class="varname"><var class="varname">class</var></var></dt>       <dd>        <p class="para">Worker 的类</p>      </dd>                 <dt id="pool.props.workers"><var class="varname"><var class="varname">workers</var></var></dt>       <dd>        <p class="para">指向 Worker 对象的引用</p>      </dd>                 <dt id="pool.props.ctor"><var class="varname"><var class="varname">ctor</var></var></dt>       <dd>        <p class="para">构造新的 Worker 对象时所需的参数</p>      </dd>                 <dt id="pool.props.last"><var class="varname"><var class="varname">last</var></var></dt>       <dd>        <p class="para">最后使用的 Worker 对象在池中的位置偏移量</p>      </dd>          </dl>    </div>     </div>                                                           <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Pool::collect} — 回收已完成任务的引用</li><li>{@link Pool::__construct} — 创建新的 Worker 对象池</li><li>{@link Pool::resize} — 改变 Pool 对象的可容纳 Worker 对象的数量</li><li>{@link Pool::shutdown} — 停止所有的 Worker 对象</li><li>{@link Pool::submit} — 提交对象以执行</li><li>{@link Pool::submitTo} — 提交一个任务到特定的 Worker 以执行</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Pool {
    /**
     * Maximum number of Workers this Pool can use
     * @var integer
     */
    protected $size;

    /**
     * The class of the Worker
     * @var string
     */
    protected $class;

    /**
     * The arguments for constructor of new Workers
     * @var array
     */
    protected $ctor;

    /**
     * References to Workers
     * @var array
     */
    protected $workers;

    /**
     * References to Threaded objects submitted to the Pool
     * @var array
     */
    protected $work;

    /**
     * Offset in workers of the last Worker used
     * @var integer
     */
    protected $last;

    /**
     * (PECL pthreads &gt;= 2.0.0)
     * Creates a new Pool of Workers
     * @link http://www.php.net/manual/en/pool.construct.php
     * @param integer $size <p>The maximum number of Workers this Pool can create</p>
     * @param string $class <p>The class for new Workers</p>
     * @param array $ctor <p>An array of arguments to be passed to new Workers</p>
     * @return Pool <p>the new Pool</p>
     */
    public function __construct( $size, $class, $ctor=[] ) {}

/**
*<div id="pool.collect" class="refentry">  <div class="refnamediv">   <h1 class="refname">Pool::collect</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::collect</span> &mdash; <span class="dc-title">回收已完成任务的引用</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-pool.collect-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Pool::collect</strong></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.types.callable.php" class="type Callable" style="color:#EAB766">Callable</a></span> <span class="parameter" style="color:#2EACF9">$collector</span></span>   ] )</div>    <p class="para rdfs-comment">    对于视为垃圾的引用，使用给定的垃圾收集器进行收集   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-pool.collect-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">collector</span></dt>      <dd>       <span>       垃圾收集器，它返回一个布尔值表示这个任务是否可以被进行垃圾收集。       仅在极少的情况下需要一个自定义的垃圾收集器。      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-pool.collect-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   池中剩余的待收集的任务数量。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 changelog" id="refsect1-pool.collect-changelog">   <h3 class="title">更新日志</h3>   <span>    <table class="doctable informaltable">           <thead>       <tr>        <th>版本</th>        <th>说明</th>       </tr>       </thead>       <tbody class="tbody">       <tr>        <td>v3</td>        <td>         <span class="parameter" style="color:#2EACF9">collector</span> 参数变为可选参数，         并且返回值改为整数。        </td>       </tr>       </tbody>          </table>    </span>  </div>      <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-pool.collect-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4396">     <p><strong>Example #1 <span class="methodname" style="color:#CC7832"><strong>Pool::collect()</strong></span> 基本用法示例</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$pool&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Pool</span><span style="color: #007700">(</span><span style="color: #9876AA">4</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #9876AA">15</span><span style="color: #007700">;&nbsp;++</span><span style="color: #9876AA">$i</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submit</span><span style="color: #007700">(new&nbsp;class&nbsp;extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{});<br />}<br /><br />while&nbsp;(</span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">collect</span><span style="color: #007700">());&nbsp;</span><span style="color: #FF8000">//&nbsp;直到全部的任务都完成执行之后才会继续下面的代码<br /><br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shutdown</span><span style="color: #007700">();</span> </span> </span></div>     </div>     </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.pool.php">Pool</a></div></div>
     * @return void*/
    public function collect( $collector ) {}

/**
*<div id="pool.resize" class="refentry">  <div class="refnamediv">   <h1 class="refname">Pool::resize</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::resize</span> &mdash; <span class="dc-title">改变 Pool 对象的可容纳 Worker 对象的数量</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-pool.resize-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><span class="type void" style="color:#EAB766">void</span></span> <span class="methodname" style="color:#CC7832"><strong>Pool::resize</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    )</div>    <p class="para rdfs-comment">   改变 Pool 对象的可容纳 Worker 对象的数量   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-pool.resize-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">size</span></dt>      <dd>       <span>       此 Pool 对象可创建 Worker 对象的最大数量      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-pool.resize-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   void   </p>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.pool.php">Pool</a></div></div>
     * @return void*/
    public function resize( $size ) {}

/**
*<div id="pool.shutdown" class="refentry">  <div class="refnamediv">   <h1 class="refname">Pool::shutdown</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::shutdown</span> &mdash; <span class="dc-title">停止所有的 Worker 对象</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-pool.shutdown-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><span class="type void" style="color:#EAB766">void</span></span> <span class="methodname" style="color:#CC7832"><strong>Pool::shutdown</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   停止此 Pool 中所有的 Worker 对象。此方法调用会进入阻塞状态，    直到所有已经提交到这个 Pool 中的任务都执行完毕。   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-pool.shutdown-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-pool.shutdown-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    无返回值   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-pool.shutdown-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4398">     <p><strong>Example #1 完全停止一个 Pool</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">Task&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Threaded<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">usleep</span><span style="color: #007700">(</span><span style="color: #9876AA">500000</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #9876AA">$pool&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Pool</span><span style="color: #007700">(</span><span style="color: #9876AA">4</span><span style="color: #007700">);<br /><br />for&nbsp;(</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">;&nbsp;++</span><span style="color: #9876AA">$i</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submit</span><span style="color: #007700">(new&nbsp;</span><span style="color: #9876AA">Task</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shutdown</span><span style="color: #007700">();&nbsp;</span><span style="color: #FF8000">//&nbsp;进入阻塞状态，直到所有已经提交到&nbsp;Pool&nbsp;中的任务都执行完毕</span> </span> </span></div>     </div>     </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.pool.php">Pool</a></div></div>
     * @return void*/
    public function shutdown() {}

/**
*<div id="pool.submit" class="refentry">  <div class="refnamediv">   <h1 class="refname">Pool::submit</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::submit</span> &mdash; <span class="dc-title">提交对象以执行</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-pool.submit-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Pool::submit</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">$task</span></span>    )</div>    <p class="para rdfs-comment">    将任务提交到 Pool 中的下一个 Worker 对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-pool.submit-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">task</span></dt>      <dd>       <span>   要执行的任务      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-pool.submit-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">  执行新加入对象的 Worker 对象 ID   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-pool.submit-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4399">     <p><strong>Example #1 提交任务</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">MyWork&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;...&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /><br />class&nbsp;</span><span style="color: #9876AA">MyWorker&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Worker&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">__construct</span><span style="color: #007700">(</span><span style="color: #9876AA">Something&nbsp;$something</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">something&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">$something</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;...&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /><br /></span><span style="color: #9876AA">$pool&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Pool</span><span style="color: #007700">(</span><span style="color: #9876AA">8</span><span style="color: #007700">,&nbsp;\</span><span style="color: #9876AA">MyWorker</span><span style="color: #007700">::class,&nbsp;[new&nbsp;</span><span style="color: #9876AA">Something</span><span style="color: #007700">()]);<br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submit</span><span style="color: #007700">(new&nbsp;</span><span style="color: #9876AA">MyWork</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$pool</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> object(Pool)#1 (6) {   [&quot;size&quot;:protected]=&gt;   int(8)   [&quot;class&quot;:protected]=&gt;   string(8) &quot;MyWorker&quot;   [&quot;workers&quot;:protected]=&gt;   array(1) {     [0]=&gt;     object(MyWorker)#4 (1) {       [&quot;something&quot;]=&gt;       object(Something)#5 (0) {       }     }   }   [&quot;work&quot;:protected]=&gt;   array(1) {     [0]=&gt;     object(MyWork)#3 (1) {       [&quot;worker&quot;]=&gt;       object(MyWorker)#5 (1) {         [&quot;something&quot;]=&gt;         object(Something)#6 (0) {         }       }     }   }   [&quot;ctor&quot;:protected]=&gt;   array(1) {     [0]=&gt;     object(Something)#2 (0) {     }   }   [&quot;last&quot;:protected]=&gt;   int(1) } </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.pool.php">Pool</a></div></div>
     * @return integer <p>the identifier of the Worker executing the object</p>*/
    public function submit( $task ) {}

/**
*<div id="pool.submitTo" class="refentry">  <div class="refnamediv">   <h1 class="refname">Pool::submitTo</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Pool::submitTo</span> &mdash; <span class="dc-title">提交一个任务到特定的 Worker 以执行</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-pool.submitTo-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Pool::submitTo</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$worker</span></span>    , <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">$task</span></span>    )</div>    <p class="para rdfs-comment">    将对象提交到 Pool 中某个特定的 Worker 对象来执行。Worker 的下标从 0 开始，    由于 Pool 中的线程是懒加载机制，    所以 Worker 对象仅在 Pool 需要执行任务的时候才会真正被创建。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-pool.submitTo-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">worker</span></dt>      <dd>       <span>       用来执行任务的 Worker 对象，下标从 <em>0</em> 开始。      </span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">task</span></dt>      <dd>       <p class="para">   要执行的任务      </p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-pool.submitTo-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">  接受新加入对象的 Worker 对象ID   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-pool.submitTo-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4400">     <p><strong>Example #1 提交任务到特定的 Worker</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">Task&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Thread</span><span style="color: #007700">::</span><span style="color: #9876AA">getCurrentThreadID</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #9876AA">$pool&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Pool</span><span style="color: #007700">(</span><span style="color: #9876AA">2</span><span style="color: #007700">);<br /><br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submit</span><span style="color: #007700">(new&nbsp;</span><span style="color: #9876AA">Task</span><span style="color: #007700">());<br /><br />for&nbsp;(</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #9876AA">5</span><span style="color: #007700">;&nbsp;++</span><span style="color: #9876AA">$i</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submitTo</span><span style="color: #007700">(</span><span style="color: #9876AA">0</span><span style="color: #007700">,&nbsp;new&nbsp;</span><span style="color: #9876AA">Task</span><span style="color: #007700">());&nbsp;</span><span style="color: #FF8000">//&nbsp;将所有的任务都入栈到下标为&nbsp;0&nbsp;的&nbsp;Worker<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">submitTo</span><span style="color: #007700">(</span><span style="color: #9876AA">1</span><span style="color: #007700">,&nbsp;new&nbsp;</span><span style="color: #9876AA">Task</span><span style="color: #007700">());&nbsp;</span><span style="color: #FF8000">//&nbsp;由于第二个&nbsp;Worker&nbsp;尚未存在，所以不可以将任务入栈到第二个&nbsp;Worker<br /><br /></span><span style="color: #9876AA">$pool</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shutdown</span><span style="color: #007700">();</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(4475011072) int(4475011072) int(4475011072) int(4475011072) int(4475011072) int(4475011072)  Fatal error: Uncaught Exception: The selected worker (1) does not exist in %s:%d </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.pool.php">Pool</a></div></div>
     * @return integer <p>the identifier of the Worker that accepted the object</p>*/
    public function submitTo( $worker, $task ) {}
}

/**
*<div id="class.threaded" class="reference">   <h1 class="title">Threaded 类</h1>     <div class="partintro"><p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p>     <div class="section" id="threaded.intro">    <h2 class="title">简介</h2>    <p class="para">   Threaded 对象提供支持 pthreads 操作的基本功能，包括同步方法以及其他对程序员很有帮助的接口。    </p>    <p class="para">     重要的是，Threaded 提供了隐式的线程安全机制，这个对象中的所有操作都是线程安全的。    </p>   </div>    <div class="section" id="threaded.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Threaded</strong>      </span>            <span class="oointerface">implements        <span class="interfacename"><a href="http://php.net/manual/zh/class.collectable.php" class="interfacename">Collectable</a></span>      </span>            <span class="oointerface">,        <span class="interfacename"><strong class="interfacename">Traversable</strong></span>      </span>       <span class="oointerface">,        <span class="interfacename"><a href="http://php.net/manual/zh/class.countable.php" class="interfacename">Countable</a></span>      </span>            <span class="oointerface">,        <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>      </span>      {</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.chunk.php" class="methodname" style="color:#CC7832">chunk</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    , <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$preserve</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.count.php" class="methodname" style="color:#CC7832">count</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.extend.php" class="methodname" style="color:#CC7832">extend</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">string</span> <span class="parameter" style="color:#2EACF9">$class</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">Threaded</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.from.php" class="methodname" style="color:#CC7832">from</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$run</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$construct</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">array</span> <span class="parameter" style="color:#2EACF9">$args</span></span>   ]] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.getterminationinfo.php" class="methodname" style="color:#CC7832">getTerminationInfo</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.isrunning.php" class="methodname" style="color:#CC7832">isRunning</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.isterminated.php" class="methodname" style="color:#CC7832">isTerminated</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.iswaiting.php" class="methodname" style="color:#CC7832">isWaiting</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.lock.php" class="methodname" style="color:#CC7832">lock</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.merge.php" class="methodname" style="color:#CC7832">merge</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$from</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$overwrite</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.notify.php" class="methodname" style="color:#CC7832">notify</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.notifyone.php" class="methodname" style="color:#CC7832">notifyOne</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.pop.php" class="methodname" style="color:#CC7832">pop</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.run.php" class="methodname" style="color:#CC7832">run</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">boolean</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.shift.php" class="methodname" style="color:#CC7832">shift</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">mixed</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.synchronized.php" class="methodname" style="color:#CC7832">synchronized</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$block</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$...</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.unlock.php" class="methodname" style="color:#CC7832">unlock</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/threaded.wait.php" class="methodname" style="color:#CC7832">wait</a></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$timeout</span></span>   ] )</div>     }</div>     </div>   </div>                                                                                                                                                                <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Threaded::chunk} — 操作</li><li>{@link Threaded::count} — 操作</li><li>{@link Threaded::extend} — Runtime Manipulation</li><li>{@link Threaded::from} — Creation</li><li>{@link Threaded::getTerminationInfo} — 错误检测</li><li>{@link Threaded::isRunning} — 状态检测</li><li>{@link Threaded::isTerminated} — 状态检测</li><li>{@link Threaded::isWaiting} — 状态检测</li><li>{@link Threaded::lock} — 同步控制</li><li>{@link Threaded::merge} — 操作</li><li>{@link Threaded::notify} — 同步控制</li><li>{@link Threaded::notifyOne} — Synchronization</li><li>{@link Threaded::pop} — 操作</li><li>{@link Threaded::run} — 执行</li><li>{@link Threaded::shift} — Manipulation</li><li>{@link Threaded::synchronized} — 同步控制</li><li>{@link Threaded::unlock} — 同步控制</li><li>{@link Threaded::wait} — Synchronization</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Threaded implements Traversable, Countable, ArrayAccess {
    /**
     * Worker object in which this Threaded is being executed
     * @var Worker
     */
    protected $worker;

/**
*<div id="threaded.chunk" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::chunk</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::chunk</span> &mdash; <span class="dc-title">操作</span></p>   </div>  <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.chunk-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::chunk</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    , <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$preserve</span></span>    )</div>    <p class="para rdfs-comment">    获取给定数量的对象属性表，可以选择是否保留键名称。   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.chunk-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">size</span></dt>      <dd>       <span>   要获取的条目数量      </span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">preserve</span></dt>      <dd>       <p class="para">   保留成员原有的键名称，默认为 false       </p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.chunk-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    数组对象，包含从对象属性表中返回的给定数量的条目。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.chunk-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4360">     <p><strong>Example #1 获取对象属性表中的部分条目</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Threaded</span><span style="color: #007700">();<br /><br />while&nbsp;(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$safe</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">chunk</span><span style="color: #007700">(</span><span style="color: #9876AA">5</span><span style="color: #007700">));<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> array(5) {   [0]=&gt;   int(0)   [1]=&gt;   int(1)   [2]=&gt;   int(2)   [3]=&gt;   int(3)   [4]=&gt;   int(4) } </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return array <p>An array of items from the objects property table</p>*/
    public function chunk( $size, $preserve ) {}

/**
*<div id="threaded.count" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::count</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::count</span> &mdash; <span class="dc-title">操作</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.count-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::count</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    返回对象的属性数量   </p>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.count-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.count-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">      </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.count-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4361">     <p><strong>Example #1 计算对象中的属性数量</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Threaded</span><span style="color: #007700">();<br /><br />while&nbsp;(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$safe</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">));<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(10) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return int <p>Returns the number of properties for this object</p>*/
    public function count() {}

/**
*<div id="threaded.getterminationinfo" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::getTerminationInfo</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Threaded::getTerminationInfo</span> &mdash; <span class="dc-title">错误检测</span></p>   </div>    <div id="threaded.getterminationinfo-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。     另外，<span class="methodname" style="color:#CC7832">{@link Threaded::run()}</span> 中的代码，     应该使用 try...catch 来进行异常检测（因为在 PHP 7 中大部分 error 都改为抛出异常的方式了）。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.getterminationinfo-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::getTerminationInfo</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   返回对象的终端错误信息   </p>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.getterminationinfo-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.getterminationinfo-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    包含终端信息的数组对象   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.getterminationinfo-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4364">     <p><strong>Example #1 检测线程运行时的致命错误</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@</span><span style="color: #9876AA">not_found</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">();<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isTerminated</span><span style="color: #007700">(),&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">getTerminationInfo</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) array(4) {   [&quot;scope&quot;]=&gt;   string(2) &quot;My&quot;   [&quot;function&quot;]=&gt;   string(3) &quot;run&quot;   [&quot;file&quot;]=&gt;   string(29) &quot;/usr/src/pthreads/sandbox.php&quot;   [&quot;line&quot;]=&gt;   int(4) } </span></div>     </div>    </div>   </span>  </div>    <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return array <p>array containing the termination conditions of the referenced object</p>*/
    public function getTerminationInfo() {}

    /**
     * (PECL pthreads &gt;= 2.0.0)
     * Tell if the referenced object is executing
     * @link http://www.php.net/manual/en/thread.isrunning.php
     * @return boolean
     */
    public function isRunning() {}

/**
*<div id="threaded.isterminated" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::isTerminated</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::isTerminated</span> &mdash; <span class="dc-title">状态检测</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.isterminated-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::isTerminated</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    检测是否因致命错误或未捕获的异常而导致执行过程异常终止   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.isterminated-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.isterminated-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示是否异常终止   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.isterminated-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4366">     <p><strong>Example #1 检测对象状态</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">i_do_not_exist</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isTerminated</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function isTerminated() {}

/**
*<div id="threaded.iswaiting" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::isWaiting</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Threaded::isWaiting</span> &mdash; <span class="dc-title">状态检测</span></p>   </div>    <div id="threaded.iswaiting-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.iswaiting-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::isWaiting</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    检测对象是否在等待其他线程唤醒   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.iswaiting-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.iswaiting-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示是否处于等待唤醒状态   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.iswaiting-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4367">     <p><strong>Example #1 检测对象状态</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #9876AA">$done</span><span style="color: #007700">;<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isWaiting</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">notify</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean <p>A boolean indication of state</p>*/
    public function isWaiting() {}

/**
*<div id="threaded.lock" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::lock</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Threaded::lock</span> &mdash; <span class="dc-title">同步控制</span></p>   </div>  <div id="threaded.lock-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。     请使用 <span class="methodname" style="color:#CC7832">{@link Threaded::synchronized()}</span> 方法。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.lock-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::lock</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   给对象属性表加锁   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.lock-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.lock-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示加锁是否成功   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.lock-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4368">     <p><strong>Example #1 给对象属性加锁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">lock</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;其他线程无法进行读/写操作&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">unlock</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;其他线程可以进行读/写操作&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function lock() {}

/**
*<div id="threaded.merge" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::merge</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::merge</span> &mdash; <span class="dc-title">操作</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.merge-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::merge</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$from</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$overwrite</span></span>   ] )</div>    <p class="para rdfs-comment">   将数据合并到当前对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.merge-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">from</span></dt>      <dd>       <span>   要合并的数据      </span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">overwrite</span></dt>      <dd>       <p class="para">   如果现有对象已经存在同键的数据，是否覆盖。默认为 true      </p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.merge-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示操作是否成功   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.merge-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4369">     <p><strong>Example #1 合并数据到对象的属性表</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$array&nbsp;</span><span style="color: #007700">=&nbsp;[];<br /><br />while&nbsp;(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$array</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$array</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$array</span><span style="color: #007700">);<br /><br /></span><span style="color: #9876AA">$stdClass&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">stdClass</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">;<br /></span><span style="color: #9876AA">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">bar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"bar"</span><span style="color: #007700">;<br /></span><span style="color: #9876AA">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">baz&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"baz"</span><span style="color: #007700">;<br /><br /></span><span style="color: #9876AA">$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Threaded</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">merge</span><span style="color: #007700">(</span><span style="color: #9876AA">$array</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">merge</span><span style="color: #007700">(</span><span style="color: #9876AA">$stdClass</span><span style="color: #007700">);<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> object(Threaded)#2 (13) {   [&quot;0&quot;]=&gt;   int(0)   [&quot;1&quot;]=&gt;   int(1)   [&quot;2&quot;]=&gt;   int(2)   [&quot;3&quot;]=&gt;   int(3)   [&quot;4&quot;]=&gt;   int(4)   [&quot;5&quot;]=&gt;   int(5)   [&quot;6&quot;]=&gt;   int(6)   [&quot;7&quot;]=&gt;   int(7)   [&quot;8&quot;]=&gt;   int(8)   [&quot;9&quot;]=&gt;   int(9)   [&quot;foo&quot;]=&gt;   string(3) &quot;foo&quot;   [&quot;bar&quot;]=&gt;   string(3) &quot;bar&quot;   [&quot;baz&quot;]=&gt;   string(3) &quot;baz&quot; } </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function merge( $from, $overwrite = null ) {}

/**
*<div id="threaded.notify" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::notify</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::notify</span> &mdash; <span class="dc-title">同步控制</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.notify-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::notify</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   向对象发送唤醒通知   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.notify-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.notify-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示操作是否成功   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.notify-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4370">     <p><strong>Example #1 等待和唤醒</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;让线程等待&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;向处于等待状态的线程发送唤醒通知&nbsp;*<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">notify</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function notify() {}

/**
*<div id="threaded.pop" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::pop</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::pop</span> &mdash; <span class="dc-title">操作</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.pop-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::pop</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   弹出对象属性表中的最后一项数据   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.pop-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   对象属性表中最后一项数据   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.pop-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4372">     <p><strong>Example #1 弹出对象属性表中的最后一项数据</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Threaded</span><span style="color: #007700">();<br /><br />while&nbsp;(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$safe</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">);<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">pop</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(9) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function pop() {}

/**
*<div id="threaded.run" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::run</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::run</span> &mdash; <span class="dc-title">执行</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.run-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><span class="type void" style="color:#EAB766">void</span></span> <span class="methodname" style="color:#CC7832"><strong>Threaded::run</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    如果需要在多线程环境下执行代码，必须实现本方法   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.run-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.run-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    无返回值。即使代码中 run 方法有返回值，也会被忽略   </p>  </div>    <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return void*/
    public function run() {}

/**
*<div id="threaded.shift" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::shift</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::shift</span> &mdash; <span class="dc-title">Manipulation</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.shift-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">boolean</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::shift</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    弹出对象属性表中第一项数据   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.shift-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   对象属性表中的第一项数据   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.shift-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4373">     <p><strong>Example #1 弹出对象属性表中第一项数据</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Threaded</span><span style="color: #007700">();<br /><br />while&nbsp;(</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #9876AA">10</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$safe</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #9876AA">count</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">);<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shift</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(0) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function shift() {}

/**
*<div id="threaded.synchronized" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::synchronized</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::synchronized</span> &mdash; <span class="dc-title">同步控制</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.synchronized-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="methodname" style="color:#CC7832"><strong>Threaded::synchronized</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$block</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$...</span></span>   ] )</div>    <p class="para rdfs-comment">    在发起调用的线程上下文中获取对象同步锁，然后同步执行代码块   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.synchronized-parameters">   <h3 class="title">参数</h3>    <dl>          <dt> <span class="parameter" style="color:#2EACF9">block</span></dt>      <dd>       <span>   要执行的代码块      </span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">...</span></dt>      <dd>       <p class="para">       传送给代码块的不定长参数      </p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.synchronized-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   代码块的返回值   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.synchronized-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4374">     <p><strong>Example #1 同步</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">notify</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return mixed*/
    public function synchronized( $block, $_ = null ) {}

/**
*<div id="threaded.unlock" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::unlock</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Threaded::unlock</span> &mdash; <span class="dc-title">同步控制</span></p>   </div>    <div id="threaded.unlock-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。     请使用 <span class="methodname" style="color:#CC7832">{@link Threaded::synchronized()}</span> 方法。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.unlock-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::unlock</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">   从调用上下文中解锁被引用的对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.unlock-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.unlock-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示操作是否成功   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.unlock-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4375">     <p><strong>Example #1 给对象属性表加锁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">lock</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;其他线程无法执行读/写操作&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">unlock</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;其他线程可以执行读/写操作&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function unlock() {}

/**
*<div id="threaded.wait" class="refentry">  <div class="refnamediv">   <h1 class="refname">Threaded::wait</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::wait</span> &mdash; <span class="dc-title">Synchronization</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-threaded.wait-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Threaded::wait</strong></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$timeout</span></span>   ] )</div>    <p class="para rdfs-comment">    让发起调用的线程上下文进入等待状态，直到收到其他线程的唤醒通知   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-threaded.wait-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">timeout</span></dt>      <dd>       <span>   可选参数，等待时间，以微秒计      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-threaded.wait-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示操作是否成功   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-threaded.wait-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4376">     <p><strong>Example #1 等待和唤醒</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;让本线程进入等待状态&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;向处于等待状态的线程发送唤醒通知&nbsp;*<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">notify</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.threaded.php">Threaded</a></div></div>
     * @return boolean*/
    public function wait( $timeout = 0 ) {}


    /**
     * Whether a offset exists
     * @link http://php.net/manual/en/arrayaccess.offsetexists.php
     * @param mixed $offset <p>
     * An offset to check for.
     * </p>
     * @return boolean true on success or false on failure.
     * </p>
     * <p>
     * The return value will be casted to boolean if non-boolean was returned.
     * @since 5.0.0
     */
    public function offsetExists($offset) {
    }

    /**
     * Offset to retrieve
     * @link http://php.net/manual/en/arrayaccess.offsetget.php
     * @param mixed $offset <p>
     * The offset to retrieve.
     * </p>
     * @return mixed Can return all value types.
     * @since 5.0.0
     */
    public function offsetGet($offset) {
    }

    /**
     * Offset to set
     * @link http://php.net/manual/en/arrayaccess.offsetset.php
     * @param mixed $offset <p>
     * The offset to assign the value to.
     * </p>
     * @param mixed $value <p>
     * The value to set.
     * </p>
     * @return void
     * @since 5.0.0
     */
    public function offsetSet($offset, $value) {
    }

    /**
     * Offset to unset
     * @link http://php.net/manual/en/arrayaccess.offsetunset.php
     * @param mixed $offset <p>
     * The offset to unset.
     * </p>
     * @return void
     * @since 5.0.0
     */
    public function offsetUnset($offset) {
    }




}

/**
 * Stackable is an alias of Threaded. This class name was used in pthreads until
 * version 2.0.0
 * @link http://www.php.net/manual/en/class.threaded.php
 */
class Stackable extends Threaded implements Traversable, Countable, ArrayAccess {

}

/**
*<div id="class.thread" class="reference">   <h1 class="title">Thread 类</h1>       <div class="partintro"><p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p>     <div class="section" id="thread.intro">    <h2 class="title">简介</h2>    <p class="para">   当调用 Thread 对象的 start 方法时，该对象的 run 方法中的代码将在独立线程中并行执行。    </p>    <p class="para">   run 方法中的代码执行完毕之后，独立线程立即退出，并且等待合适的时机由创建者线程加入（join）。       </p>    <div class="warning"><strong class="warning">Warning</strong>    <p class="para">   依赖于引擎本身的机制检测何时加入线程可能引发非预期的行为，程序员应该尽可能的显式控制线程加入的时机。      </p>    </div>   </div>     <div class="section" id="thread.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Thread</strong>      </span>            <span class="ooclass">       <span class="modifier">extends</span>       <a href="http://php.net/manual/zh/class.threaded.php" class="classname">Threaded</a>      </span>            <span class="oointerface">implements        <span class="interfacename"><a href="http://php.net/manual/zh/class.countable.php" class="interfacename">Countable</a></span>      </span>       <span class="oointerface">,        <span class="interfacename"><strong class="interfacename">Traversable</strong></span>      </span>            <span class="oointerface">,        <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>      </span>      {</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.detach.php" class="methodname" style="color:#CC7832">detach</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.getcreatorid.php" class="methodname" style="color:#CC7832">getCreatorId</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">Thread</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.getcurrentthread.php" class="methodname" style="color:#CC7832">getCurrentThread</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.getcurrentthreadid.php" class="methodname" style="color:#CC7832">getCurrentThreadId</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.getthreadid.php" class="methodname" style="color:#CC7832">getThreadId</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">mixed</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.globally.php" class="methodname" style="color:#CC7832">globally</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.isjoined.php" class="methodname" style="color:#CC7832">isJoined</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.isstarted.php" class="methodname" style="color:#CC7832">isStarted</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.join.php" class="methodname" style="color:#CC7832">join</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.kill.php" class="methodname" style="color:#CC7832">kill</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/thread.start.php" class="methodname" style="color:#CC7832">start</a></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$options</span></span>   ] )</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 继承的方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832">{@link Threaded::chunk}</span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$size</span></span>    , <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$preserve</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832">{@link Threaded::count}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::extend}</span>     ( <span class="methodparam"><span class="type" style="color:#EAB766">string</span> <span class="parameter" style="color:#2EACF9">$class</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">Threaded</span> <span class="methodname" style="color:#CC7832">{@link Threaded::from}</span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$run</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$construct</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">array</span> <span class="parameter" style="color:#2EACF9">$args</span></span>   ]] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">array</span> <span class="methodname" style="color:#CC7832">{@link Threaded::getTerminationInfo}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::isRunning}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::isTerminated}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::isWaiting}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::lock}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::merge}</span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$from</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766">bool</span> <span class="parameter" style="color:#2EACF9">$overwrite</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::notify}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::notifyOne}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::pop}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832">{@link Threaded::run}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">boolean</span> <span class="methodname" style="color:#CC7832">{@link Threaded::shift}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">mixed</span> <span class="methodname" style="color:#CC7832">{@link Threaded::synchronized}</span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.closure.php" class="type Closure" style="color:#EAB766">Closure</a></span> <span class="parameter" style="color:#2EACF9">$block</span></span>    [, <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="parameter" style="color:#2EACF9">$...</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::unlock}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Threaded::wait}</span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$timeout</span></span>   ] )</div>      }</div>     </div>   </div>                                                                                                        <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Thread::detach} — 执行</li><li>{@link Thread::getCreatorId} — 识别</li><li>{@link Thread::getCurrentThread} — 识别</li><li>{@link Thread::getCurrentThreadId} — 识别</li><li>{@link Thread::getThreadId} — 识别</li><li>{@link Thread::globally} — 执行</li><li>{@link Thread::isJoined} — 状态监测</li><li>{@link Thread::isStarted} — 状态检测</li><li>{@link Thread::join} — 同步</li><li>{@link Thread::kill} — 执行</li><li>{@link Thread::start} — 执行</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Thread extends Threaded implements Traversable, Countable, ArrayAccess {
/**
*<div id="thread.detach" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::detach</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Thread::detach</span> &mdash; <span class="dc-title">执行</span></p>   </div>    <div id="thread.detach-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经移除此方法.    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.detach-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><span class="type void" style="color:#EAB766">void</span></span> <span class="methodname" style="color:#CC7832"><strong>Thread::detach</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    从调用上下文中将引用线程分离出来，非常危险！   </p>   <div class="warning"><strong class="warning">Warning</strong>   <p class="para">    本方法会引发未定义的、不安全的行为。    通常情况下不会用到本方法，提供这个方法主要是出于完备性以及高级用法的考虑。   </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.detach-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.detach-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">       </p>  </div>    <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return void*/
    public function detach() {}

/**
*<div id="thread.getcreatorid" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::getCreatorId</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::getCreatorId</span> &mdash; <span class="dc-title">识别</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.getcreatorid-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Thread::getCreatorId</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    返回创建当前线程的线程ID。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.getcreatorid-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.getcreatorid-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   线程ID，数字格式   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.getcreatorid-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4377">     <p><strong>Example #1 返回创建线程的线程或进程ID</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;created&nbsp;by&nbsp;Thread&nbsp;#%lu\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">__CLASS__</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">getCreatorId</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> My created by Thread #123456778899 </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return int <p>A numeric identity</p>*/
    public function getCreatorId() {}

/**
*<div id="thread.getcurrentthread" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::getCurrentThread</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::getCurrentThread</span> &mdash; <span class="dc-title">识别</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.getcurrentthread-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.thread.php" class="type Thread" style="color:#EAB766">Thread</a></span> <span class="methodname" style="color:#CC7832"><strong>Thread::getCurrentThread</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    获取当前执行线程的引用。   </p>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.getcurrentthread-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.getcurrentthread-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    表示当前执行线程的对象。   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.getcurrentthread-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4378">     <p><strong>Example #1 获取当前执行线程</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Thread</span><span style="color: #007700">::</span><span style="color: #9876AA">getCurrentThread</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> object(My)#2 (0) { } </span></div>     </div>    </div>   </span>  </div>    <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return Thread <p>An object representing the currently executing Thread</p>*/
    public static function getCurrentThread() {}

/**
*<div id="thread.getcurrentthreadid" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::getCurrentThreadId</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::getCurrentThreadId</span> &mdash; <span class="dc-title">识别</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.getcurrentthreadid-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Thread::getCurrentThreadId</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    返回当前执行线程的ID   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.getcurrentthreadid-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.getcurrentthreadid-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   线程ID，数字格式   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.getcurrentthreadid-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4379">     <p><strong>Example #1 返回当前执行线程的ID</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;is&nbsp;Thread&nbsp;#%lu\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">__CLASS__</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">Thread</span><span style="color: #007700">::</span><span style="color: #9876AA">getCurrentThreadId</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> My is Thread #123456778899 </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return int <p>A numeric identity</p>*/
    public static function getCurrentThreadId() {}

/**
*<div id="thread.getthreadid" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::getThreadId</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::getThreadId</span> &mdash; <span class="dc-title">识别</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.getthreadid-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Thread::getThreadId</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    返回引用线程的ID   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.getthreadid-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.getthreadid-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   线程ID，数字格式   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.getthreadid-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4380">     <p><strong>Example #1 返回引用线程的ID</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;is&nbsp;Thread&nbsp;#%lu\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">__CLASS__</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">getThreadId</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> My is Thread #123456778899 </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return int <p>A numeric identity</p>*/
    public function getThreadId() {}

/**
*<div id="thread.globally" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::globally</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Thread::globally</span> &mdash; <span class="dc-title">执行</span></p>   </div>    <div id="thread.globally-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.globally-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.pseudo-types.php#language.types.mixed" class="type mixed" style="color:#EAB766">mixed</a></span> <span class="methodname" style="color:#CC7832"><strong>Thread::globally</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    在全局范围中执行代码块   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.globally-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.globally-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    被调用代码块的返回值   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.globally-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4381">     <p><strong>Example #1 在全局范围执行代码块</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;</span><span style="color: #9876AA">$std</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">Thread</span><span style="color: #007700">::</span><span style="color: #9876AA">globally</span><span style="color: #007700">(function(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$std&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">stdClass</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$std</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> object(stdClass)#3 (0) { } </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return mixed <p>The return value of the Callable</p>*/
    public static function globally() {}

/**
*<div id="thread.isjoined" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::isJoined</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::isJoined</span> &mdash; <span class="dc-title">状态监测</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.isjoined-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Thread::isJoined</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    线程是否已经被加入（join）   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.isjoined-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.isjoined-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    布尔值，表示是否被加入   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.isjoined-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4382">     <p><strong>Example #1 检测线程状态</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">wait</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;</span><span style="color: #9876AA">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isJoined</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">synchronized</span><span style="color: #007700">(function(</span><span style="color: #9876AA">$thread</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">done&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$thread</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">notify</span><span style="color: #007700">();<br />},&nbsp;</span><span style="color: #9876AA">$my</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(false) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return boolean <p>A boolean indication of state</p>*/
    public function isJoined() {}

/**
*<div id="thread.isstarted" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::isStarted</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::isStarted</span> &mdash; <span class="dc-title">状态检测</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.isstarted-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Thread::isStarted</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    线程是否开始执行   </p>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.isstarted-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.isstarted-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    布尔值，表示线程是否开始执行   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.isstarted-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4383">     <p><strong>Example #1 监测线程是否开始执行</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$worker&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isStarted</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return boolean <p>A boolean indication of state</p>*/
    public function isStarted() {}

/**
*<div id="thread.join" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::join</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::join</span> &mdash; <span class="dc-title">同步</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.join-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Thread::join</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    让当前执行上下文等待被引用线程执行完毕   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.join-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.join-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    布尔值，表示操作成功与否   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.join-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4384">     <p><strong>Example #1 加入线程</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;...&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//&nbsp;...&nbsp;<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">join</span><span style="color: #007700">());<br /></span><span style="color: #FF8000">//&nbsp;...&nbsp;<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return boolean <p>A boolean indication of success</p>*/
    public function join() {}

/**
*<div id="thread.kill" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::kill</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Thread::kill</span> &mdash; <span class="dc-title">执行</span></p>   </div>    <div id="thread.kill-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.kill-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766"><span class="type void" style="color:#EAB766">void</span></span> <span class="methodname" style="color:#CC7832"><strong>Thread::kill</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    强制线程中止   </p>   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     通常情况下，程序员不应该强制杀除线程    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.kill-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.kill-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">    布尔值，表示操作成功与否   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.kill-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4385">     <p><strong>Example #1 杀除线程</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">T&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$stdin&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"php://stdin"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while((</span><span style="color: #9876AA">$line&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">fgets</span><span style="color: #007700">(</span><span style="color: #9876AA">$stdin</span><span style="color: #007700">)))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #9876AA">$line</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #9876AA">$t&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">T</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$t</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$t</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">kill</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>    <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return bool <p>A boolean indication of success</p>*/
    public function kill() {}

/**
*<div id="thread.start" class="refentry">  <div class="refnamediv">   <h1 class="refname">Thread::start</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Thread::start</span> &mdash; <span class="dc-title">执行</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-thread.start-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Thread::start</strong></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$options</span></span>   ] )</div>    <p class="para rdfs-comment">    在独立线程中执行 run 方法   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-thread.start-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">options</span></dt>      <dd>       <span>       可选参数，用来控制线程继承。默认值为 PTHREADS_INHERIT_ALL      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-thread.start-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示操作成功与否   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-thread.start-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4386">     <p><strong>Example #1 开始线程</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #9876AA">My&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #9876AA">Thread&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #9876AA">run</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//*&nbsp;...&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />}<br /></span><span style="color: #9876AA">$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">My</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">());<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.thread.php">Thread</a></div></div>
     * @return boolean <p>A boolean indication of success</p>*/
    public function start( $options = 0 ) {}

}

/**
*<div id="class.worker" class="reference">   <h1 class="title">Worker 类</h1>     <div class="partintro"><p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p>     <div class="section" id="worker.intro">    <h2 class="title">简介</h2>    <p class="para">     Worker 是一个具有持久化上下文的线程对象，通常用来在多个线程中使用。    </p>    <p class="para">     当一个 Worker 对象开始之后，会执行它的 run 方法，但是即使 run 方法执行完毕，线程本身也不会消亡，除非遇到以下情况：    </p>    <ul class="itemizedlist">     <li class="listitem">     <p class="para">Worker 对象超出作用范围（没有指向它的引用了）</p>     </li>     <li class="listitem">     <p class="para">代码调用了 Worker 对象的 shutdown 方法</p>     </li>     <li class="listitem">     <p class="para">整个脚本终止了</p>     </li>    </ul>    <p class="para">     这意味着程序员可以在程序执行过程中重用这个线程上下文：     在 Worker 对象的栈中添加对象会激活 Worker 对象执行被加入对象的 run 方法。    </p>   </div>     <div class="section" id="worker.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Worker</strong>      </span>            <span class="ooclass">       <span class="modifier">extends</span>       <a href="http://php.net/manual/zh/class.thread.php" class="classname">Thread</a>      </span>            <span class="oointerface">implements        <span class="interfacename"><strong class="interfacename">Traversable</strong></span>      </span>       <span class="oointerface">,        <span class="interfacename"><a href="http://php.net/manual/zh/class.countable.php" class="interfacename">Countable</a></span>      </span>            <span class="oointerface">,        <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>      </span>      {</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.collect.php" class="methodname" style="color:#CC7832">collect</a></span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/language.types.callable.php" class="type Callable" style="color:#EAB766">Callable</a></span> <span class="parameter" style="color:#2EACF9">$collector</span></span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.getstacked.php" class="methodname" style="color:#CC7832">getStacked</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.isshutdown.php" class="methodname" style="color:#CC7832">isShutdown</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.isworking.php" class="methodname" style="color:#CC7832">isWorking</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.shutdown.php" class="methodname" style="color:#CC7832">shutdown</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.stack.php" class="methodname" style="color:#CC7832">stack</a></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">&$work</span></span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/worker.unstack.php" class="methodname" style="color:#CC7832">unstack</a></span>     ( <span class="methodparam">void</span>    )</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 继承的方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832">{@link Thread::detach}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832">{@link Thread::getCreatorId}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">Thread</span> <span class="methodname" style="color:#CC7832">{@link Thread::getCurrentThread}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832">{@link Thread::getCurrentThreadId}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832">{@link Thread::getThreadId}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="modifier">static</span> <span class="type" style="color:#EAB766">mixed</span> <span class="methodname" style="color:#CC7832">{@link Thread::globally}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Thread::isJoined}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Thread::isStarted}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Thread::join}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">void</span> <span class="methodname" style="color:#CC7832">{@link Thread::kill}</span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832">{@link Thread::start}</span>     ([ <span class="methodparam"><span class="type" style="color:#EAB766">int</span> <span class="parameter" style="color:#2EACF9">$options</span></span>   ] )</div>      }</div>     </div>   </div>                                                                  <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Worker::collect} — Collect references to completed tasks</li><li>{@link Worker::getStacked} — 获取剩余的栈大小</li><li>{@link Worker::isShutdown} — 状态检测</li><li>{@link Worker::isWorking} — 状态检测</li><li>{@link Worker::shutdown} — 关闭 Worker</li><li>{@link Worker::stack} — 将要执行的任务入栈</li><li>{@link Worker::unstack} — 将要执行的任务出栈</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Worker extends Thread implements Traversable, Countable, ArrayAccess {
/**
*<div id="worker.getstacked" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::getStacked</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::getStacked</span> &mdash; <span class="dc-title">获取剩余的栈大小</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.getstacked-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Worker::getStacked</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    返回栈中剩余的任务数量   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.getstacked-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.getstacked-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   返回 worker 中等待执行的任务数量   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.getstacked-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4388">     <p><strong>Example #1 <strong class="classname">Worker::getStacked</strong> 基本示例</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$worker&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /><br />for&nbsp;(</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #9876AA">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #9876AA">5</span><span style="color: #007700">;&nbsp;++</span><span style="color: #9876AA">$i</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">stack</span><span style="color: #007700">(new&nbsp;class&nbsp;extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{});<br />}<br /><br />echo&nbsp;</span><span style="color: #DD0000">"There&nbsp;are&nbsp;</span><span style="color: #007700">{</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">getStacked</span><span style="color: #007700">()}</span><span style="color: #DD0000">&nbsp;stacked&nbsp;tasks\n"</span><span style="color: #007700">;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> There are 5 stacked tasks </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return int <p>An numeric value</p>*/
    public function getStacked() {}

/**
*<div id="worker.isshutdown" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::isShutdown</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::isShutdown</span> &mdash; <span class="dc-title">状态检测</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.isshutdown-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Worker::isShutdown</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    Worker 对象是否被关闭   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.isshutdown-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.isshutdown-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示 worker 是否已经被关闭   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.isshutdown-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4389">     <p><strong>Example #1 检测 Worker 对象状态</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$worker&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isShutdown</span><span style="color: #007700">());<br /><br /></span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shutdown</span><span style="color: #007700">();<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isShutdown</span><span style="color: #007700">());</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(false) bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return boolean <p>A boolean indication of state</p>*/
    public function isShutdown() {}

/**
*<div id="worker.isworking" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::isWorking</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::isWorking</span> &mdash; <span class="dc-title">状态检测</span></p>   </div>   <div id="worker.isworking-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已移除此方法。     请使用 <span class="methodname" style="color:#CC7832">{@link Worker::getStacked()}</span> 方法来检测 worker 中是还有     尚待执行的任务。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.isworking-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Worker::isWorking</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    Worker 对象是否正在执行栈中对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.isworking-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.isworking-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示 Worker 对象是否在执行栈中对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.isworking-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4390">     <p><strong>Example #1 检测 Worker 对象状态</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//&nbsp;...&nbsp;<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">isWorking</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;...&nbsp;the&nbsp;Worker&nbsp;is&nbsp;busy&nbsp;executing&nbsp;another&nbsp;object&nbsp;<br /></span><span style="color: #007700">}<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>     </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return boolean <p>A boolean indication of state</p>*/
    public function isWorking() {}

/**
*<div id="worker.shutdown" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::shutdown</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::shutdown</span> &mdash; <span class="dc-title">关闭 Worker </span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.shutdown-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">bool</span> <span class="methodname" style="color:#CC7832"><strong>Worker::shutdown</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    在执行完已入栈对象之后，关闭这个 Worker 对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.shutdown-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.shutdown-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   布尔值，表示这个 worker 是否被成功关闭。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.shutdown-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4391">     <p><strong>Example #1 关闭 Worker</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">start</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//&nbsp;入栈和执行任务&nbsp;<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">shutdown</span><span style="color: #007700">());</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return boolean*/
    public function shutdown() {}

/**
*<div id="worker.stack" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::stack</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::stack</span> &mdash; <span class="dc-title">将要执行的任务入栈</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.stack-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Worker::stack</strong></span>     ( <span class="methodparam"><span class="type" style="color:#EAB766"><a href="http://php.net/manual/zh/class.threaded.php" class="type Threaded" style="color:#EAB766">Threaded</a></span> <span class="parameter" style="color:#2EACF9">&$work</span></span>    )</div>    <p class="para rdfs-comment">    将要执行的任务入栈到 Worker 对象   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.stack-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">work</span></dt>      <dd>       <span>       要被 Worker 执行的 <a href="http://php.net/manual/zh/class.threaded.php" class="classname">Threaded</a> 派生对象      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.stack-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   入栈之后，Worker 对象栈的大小。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.stack-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4392">     <p><strong>Example #1 向 Worker 中入栈任务并执行</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$worker&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$work&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;class&nbsp;extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{};<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">stack</span><span style="color: #007700">(</span><span style="color: #9876AA">$work</span><span style="color: #007700">));</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(1) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return int <p>The new length of the stack</p>*/
    public function stack( &$work ) {}

/**
*<div id="worker.unstack" class="refentry">  <div class="refnamediv">   <h1 class="refname">Worker::unstack</h1>   <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Worker::unstack</span> &mdash; <span class="dc-title">将要执行的任务出栈</span></p>   </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-worker.unstack-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">public</span> <span class="type" style="color:#EAB766">int</span> <span class="methodname" style="color:#CC7832"><strong>Worker::unstack</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">    把 Worker 栈顶的（最老的那个）任务从栈中移除。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-worker.unstack-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-worker.unstack-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">   出栈之后，Worker 栈的大小。   </p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 changelog" id="refsect1-worker.unstack-changelog">   <h3 class="title">更新日志</h3>   <span>    <table class="doctable informaltable">           <thead>       <tr>        <th>版本</th>        <th>说明</th>       </tr>       </thead>       <tbody class="tbody">       <tr>        <td>v3</td>        <td>         移除了要出栈的任务参数。         现在只能移除栈顶元素。        </td>       </tr>       </tbody>         </table>    </span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-worker.unstack-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4393">     <p><strong>Example #1 从 Worker 栈中移除对象</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br />$my&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #9876AA">Worker</span><span style="color: #007700">();<br /></span><span style="color: #9876AA">$work&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;class&nbsp;extends&nbsp;</span><span style="color: #9876AA">Threaded&nbsp;</span><span style="color: #007700">{};<br /><br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">stack</span><span style="color: #007700">(</span><span style="color: #9876AA">$work</span><span style="color: #007700">));<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$my</span><span style="color: #007700">-&gt;</span><span style="color: #9876AA">unstack</span><span style="color: #007700">());</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(1) int(0) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.worker.php">Worker</a></div></div>
     * @return int <p>The new length of the stack</p>*/
    public function unstack( &$work = null ) {}

}

/**
*<div id="class.mutex" class="reference">   <h1 class="title">Mutex 类</h1>     <div class="partintro"><p class="verinfo">(PECL pthreads &lt; 3.0.0)</p>     <div class="section" id="mutex.intro">    <h2 class="title">简介</h2>    <div class="warning"><strong class="warning">Warning</strong>     <p class="para">      pthreads v3 中已经将 <strong class="classname">Mutex</strong> 类移除。     </p>    </div>    <p class="para">     Mutex 类中包含一些直接访问 Posix 互斥量的静态方法    </p>   </div>     <div class="section" id="mutex.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Mutex</strong>      </span>      {</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">   <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">int</span>    <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/mutex.create.php" class="methodname" style="color:#CC7832">create</a></span>    ([ <span class="methodparam">  <span class="type" style="color:#EAB766">bool</span>   <span class="parameter" style="color:#2EACF9">$lock</span>   </span>   ] )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">  <span class="modifier">final</span>   <span class="modifier">public</span>   <span class="modifier">static</span>   <span class="type" style="color:#EAB766">bool</span>   <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/mutex.destroy.php" class="methodname" style="color:#CC7832">destroy</a></span>   ( <span class="methodparam">   <span class="type" style="color:#EAB766">int</span>    <span class="parameter" style="color:#2EACF9">$mutex</span>  </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/mutex.lock.php" class="methodname" style="color:#CC7832">lock</a></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>   </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/mutex.trylock.php" class="methodname" style="color:#CC7832">trylock</a></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>   </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/mutex.unlock.php" class="methodname" style="color:#CC7832">unlock</a></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>  </span>    [, <span class="methodparam">  <span class="type" style="color:#EAB766">bool</span>   <span class="parameter" style="color:#2EACF9">$destroy</span>   </span>   ] )</div>     }</div>     </div>   </div>                                                  <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Mutex::create} — 创建一个互斥量</li><li>{@link Mutex::destroy} — 销毁互斥量</li><li>{@link Mutex::lock} — 给互斥量加锁</li><li>{@link Mutex::trylock} — 尝试给互斥量加锁</li><li>{@link Mutex::unlock} — 释放互斥量上的锁</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Mutex {
/**
*<div id="mutex.create" class="refentry">  <div class="refnamediv">   <h1 class="refname">Mutex::create</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Mutex::create</span> &mdash; <span class="dc-title">创建一个互斥量</span></p>   </div>    <div id="mutex.create-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.mutex.php" class="classname">Mutex</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-mutex.create-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">   <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">int</span>    <span class="methodname" style="color:#CC7832"><strong>Mutex::create</strong></span>    ([ <span class="methodparam">  <span class="type" style="color:#EAB766">bool</span>   <span class="parameter" style="color:#2EACF9">$lock</span>   </span>   ] )</div>    <p class="para rdfs-comment">为调用者创建一个互斥量，同时也可以通过 lock 参数设置是否在创建完成之后立即加锁此互斥量</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-mutex.create-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">lock</span></dt>      <dd>       <span>如果设置 lock 参数为 true，表示创建互斥量之后，立即加锁，然后再将互斥量句柄返回给调用者</span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-mutex.create-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">新创建的互斥量句柄，这个互斥量可能已经处于加锁状态，由 lock 参数控制</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-mutex.create-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4401">     <p><strong>Example #1 互斥量的创建与销毁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为互斥量不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;你已经持有了这个互斥量的物理地址&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//*&nbsp;不要忘记销毁你创建的互斥量&nbsp;*<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(40096976) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.mutex.php">Mutex</a></div></div>
     * @return int <p>A newly created and optionally locked Mutex handle</p>*/
    final public static function create ( $lock = false ) {}

/**
*<div id="mutex.destroy" class="refentry">  <div class="refnamediv">   <h1 class="refname">Mutex::destroy</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Mutex::destroy</span> &mdash; <span class="dc-title">销毁互斥量</span></p>   </div>    <div id="mutex.destroy-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.mutex.php" class="classname">Mutex</a> 类移除。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-mutex.destroy-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">  <span class="modifier">final</span>   <span class="modifier">public</span>   <span class="modifier">static</span>   <span class="type" style="color:#EAB766">bool</span>   <span class="methodname" style="color:#CC7832"><strong>Mutex::destroy</strong></span>   ( <span class="methodparam">   <span class="type" style="color:#EAB766">int</span>    <span class="parameter" style="color:#2EACF9">$mutex</span>  </span>    )</div>    <p class="para rdfs-comment">当不再使用某个已经创建的互斥量句柄之后，程序员需要显式的销毁它。 </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-mutex.destroy-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">mutex</span></dt>      <dd>       <span>       通过调用函数 <span class="function">{@link Mutex::create()}</span> 返回的互斥量句柄。       当调用 <span class="function"><strong style="color:#CC7832">Mutex::destroy()</strong></span> 函数之后，任何线程都无法再给这个互斥量加锁了。      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-mutex.destroy-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">布尔值，表示操作是否成功</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-mutex.destroy-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4402">     <p><strong>Example #1 互斥量的创建与销毁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为互斥量不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;你已经持有了这个互斥量的物理地址&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//*&nbsp;不要忘记销毁你创建的互斥量&nbsp;*<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(40096976) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.mutex.php">Mutex</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function destroy( $mutex ) {}

/**
*<div id="mutex.lock" class="refentry">  <div class="refnamediv">   <h1 class="refname">Mutex::lock</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Mutex::lock</span> &mdash; <span class="dc-title">给互斥量加锁</span></p>   </div>   <div id="mutex.lock-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.mutex.php" class="classname">Mutex</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-mutex.lock-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Mutex::lock</strong></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>   </span>    )</div>    <p class="para rdfs-comment">尝试为调用者给互斥量加锁。</p>  <p class="para">尝试给已经被其他线程加锁的互斥量再次加锁会导致调用者线程进入阻塞状态。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-mutex.lock-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">mutex</span></dt>      <dd>       <span>通过调用函数 <span class="function">{@link Mutex::create()}</span> 产生的互斥量句柄。</span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-mutex.lock-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">布尔值，表示操作是否成功。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-mutex.lock-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4403">     <p><strong>Example #1 互斥量加锁与解锁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为互斥量不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;现在可以在任何线程上下文中给这个互斥量加锁了&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">lock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;销毁一个处于加锁状态的互斥量的操作是无效的&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">unlock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的互斥量&nbsp;*<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.mutex.php">Mutex</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function lock( $mutex ) {}

/**
*<div id="mutex.trylock" class="refentry">  <div class="refnamediv">   <h1 class="refname">Mutex::trylock</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Mutex::trylock</span> &mdash; <span class="dc-title">尝试给互斥量加锁</span></p>   </div>   <div id="mutex.trylock-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.mutex.php" class="classname">Mutex</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-mutex.trylock-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Mutex::trylock</strong></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>   </span>    )</div>    <p class="para rdfs-comment">尝试给一个互斥量加锁，即使这个互斥量已经被其他线程锁定，也不会导致调用者线程进入阻塞状态。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-mutex.trylock-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">mutex</span></dt>      <dd>       <span>通过调用函数 <span class="function">{@link Mutex::create()}</span> 产生的互斥量句柄。</span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-mutex.trylock-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">  布尔值，表示操作是否成功   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-mutex.trylock-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4404">     <p><strong>Example #1 互斥量的加锁与解锁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为互斥量不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;现在可以在任何线程上下文中给这个互斥量加锁了&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">lock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;销毁一个处于加锁状态的互斥量的操作是无效的&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">unlock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的互斥量&nbsp;*<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.mutex.php">Mutex</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function trylock( $mutex ) {}

/**
*<div id="mutex.unlock" class="refentry">  <div class="refnamediv">   <h1 class="refname">Mutex::unlock</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Mutex::unlock</span> &mdash; <span class="dc-title">释放互斥量上的锁</span></p>   </div>   <div id="mutex.unlock-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.mutex.php" class="classname">Mutex</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-mutex.unlock-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Mutex::unlock</strong></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$mutex</span>  </span>    [, <span class="methodparam">  <span class="type" style="color:#EAB766">bool</span>   <span class="parameter" style="color:#2EACF9">$destroy</span>   </span>   ] )</div>    <p class="para rdfs-comment">    尝试为互斥量解锁，也可以通过 destroy 参数控制是否在解锁之后同时销毁此互斥量。    只有持有互斥量锁的线程才可以对这个互斥量进行解锁操作。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-mutex.unlock-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">mutex</span></dt>      <dd>       <span>通过调用函数 <span class="function">{@link Mutex::create()}</span> 产生的互斥量句柄。</span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">destroy</span></dt>      <dd>       <p class="para">此参数为 true 表示如果解锁成功，则同时销毁此互斥量。</p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-mutex.unlock-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">A boolean indication of success.</p>  </div>     <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-mutex.unlock-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4405">     <p><strong>Example #1 互斥量的加锁与解锁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为互斥量不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;现在可以在任何线程上下文中给这个互斥量加锁了&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">lock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;销毁一个处于加锁状态的互斥量的操作是无效的&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">unlock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的互斥量&nbsp;*<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.mutex.php">Mutex</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function unlock( $mutex, $destroy = false ) {}
}

/**
*<div id="class.cond" class="reference">   <h1 class="title">Cond 类</h1>     <div class="partintro"><p class="verinfo">(PECL pthreads &lt; 3.0.0)</p>     <div class="section" id="cond.intro">    <h2 class="title">简介</h2>    <div class="warning"><strong class="warning">Warning</strong>     <p class="para">      pthreads v3 中已经将 <strong class="classname">Cond</strong> 类移除。     </p>    </div>     <p class="para">     Cond 类中的静态方法可以用来直接访问 Posix 的条件变量。    </p>   </div>     <div class="section" id="cond.synopsis">    <h2 class="title">类摘要</h2>      <div class="classsynopsis">     <div class="ooclass"></div>       <div class="classsynopsisinfo">      <span class="ooclass">       <strong class="classname">Cond</strong>      </span>      {</div>           <div class="classsynopsisinfo classsynopsisinfo_comment">// 方法 </div>     <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/cond.broadcast.php" class="methodname" style="color:#CC7832">broadcast</a></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">int</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/cond.create.php" class="methodname" style="color:#CC7832">create</a></span>     ( <span class="methodparam">void</span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/cond.destroy.php" class="methodname" style="color:#CC7832">destroy</a></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/cond.signal.php" class="methodname" style="color:#CC7832">signal</a></span>     ( <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div> <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><a href="http://php.net/manual/zh/cond.wait.php" class="methodname" style="color:#CC7832">wait</a></span>     ( <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$condition</span>    </span>    , <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$mutex</span>    </span>    [, <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$timeout</span>   </span>   ] )</div>     }</div>     </div>   </div>                                                  <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li>{@link Cond::broadcast} — 广播条件变量</li><li>{@link Cond::create} — 创建一个条件变量</li><li>{@link Cond::destroy} — 销毁条件变量</li><li>{@link Cond::signal} — 发送唤醒信号</li><li>{@link Cond::wait} — 等待</li></ul> <div class="up"><a href="http://php.net/manual/zh/book.pthreads.php">pthreads</a></div></div>
*/
class Cond {
/**
*<div id="cond.broadcast" class="refentry">  <div class="refnamediv">   <h1 class="refname">Cond::broadcast</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Cond::broadcast</span> &mdash; <span class="dc-title">广播条件变量</span></p>   </div>    <div id="cond.broadcast-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.cond.php" class="classname">Cond</a> 类移除。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-cond.broadcast-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Cond::broadcast</strong></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div>    <p class="para rdfs-comment">向所有由于调用 <span class="function">{@link Cond::wait()}</span> 函数而进入条件阻塞状态的线程发送广播。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-cond.broadcast-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">condition</span></dt>      <dd>       <span>通过调用函数 <span class="function">{@link Cond::create()}</span> 获得的条件变量句柄。</span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-cond.broadcast-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">  布尔值，表示操作是否成功。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-cond.broadcast-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4406">     <p><strong>Example #1 广播条件变量</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为&nbsp;Cond&nbsp;不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$cond&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;调用者必须给关联的互斥量加锁，然后才可以进行广播（调用&nbsp;broadcast&nbsp;方法）&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">broadcast</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的条件变量&nbsp;*<br /></span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.cond.php">Cond</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function broadcast( $condition ) {}

/**
*<div id="cond.create" class="refentry">  <div class="refnamediv">   <h1 class="refname">Cond::create</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Cond::create</span> &mdash; <span class="dc-title">创建一个条件变量</span></p>   </div>   <div id="cond.create-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.cond.php" class="classname">Cond</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-cond.create-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>    <span class="modifier">public</span>    <span class="modifier">static</span>    <span class="type" style="color:#EAB766">int</span>     <span class="methodname" style="color:#CC7832"><strong>Cond::create</strong></span>     ( <span class="methodparam">void</span>    )</div>    <p class="para rdfs-comment">创建一个条件变量。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-cond.create-parameters">   <h3 class="title">参数</h3>   <span>此函数没有参数。</span>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-cond.create-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">指向条件变量的句柄。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-cond.create-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4407">     <p><strong>Example #1 条件变量的创建与销毁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为&nbsp;Cond&nbsp;不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$cond&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;现在你可以在任意线程上下文中使用此条件变量&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的条件变量&nbsp;*<br /></span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(4540682) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.cond.php">Cond</a></div></div>
     * @return int <p>A handle to a Condition Variable</p>*/
    final public static function create() {}

/**
*<div id="cond.destroy" class="refentry">  <div class="refnamediv">   <h1 class="refname">Cond::destroy</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Cond::destroy</span> &mdash; <span class="dc-title">销毁条件变量</span></p>   </div>   <div id="cond.destroy-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.cond.php" class="classname">Cond</a> 类移除。    </p>   </div>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-cond.destroy-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Cond::destroy</strong></span>     ( <span class="methodparam">  <span class="type" style="color:#EAB766">int</span>   <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div>    <p class="para rdfs-comment">    当不再需要所创建的条件变量时，程序员必须显式的销毁它。    当调用 <span class="function"><strong style="color:#CC7832">Cond::destroy()</strong></span> 函数时，必须保证其他线程没有处于等待此条件变量的阻塞状态（通过调用函数 <span class="function">{@link Cond::wait()}</span> 进入条件阻塞状态）。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-cond.destroy-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">condition</span></dt>      <dd>       <span>  通过调用 <span class="function">{@link Cond::create()}</span> 函数获得的条件变量句柄      </span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-cond.destroy-returnvalues">   <h3 class="title">返回值</h3>   <p class="para"> 布尔值，表示操作是否成功。   </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-cond.destroy-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4408">     <p><strong>Example #1 条件变量的创建与销毁</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为&nbsp;Cond&nbsp;不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$cond&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;现在你可以在任意线程上下文中使用此条件变量&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的条件变量&nbsp;*<br /></span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(4540682) </span></div>     </div>    </div>   </span>  </div>  <div class="up"><a href="http://php.net/manual/zh/class.cond.php">Cond</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function destroy( $condition ) {}

/**
*<div id="cond.signal" class="refentry">  <div class="refnamediv">   <h1 class="refname">Cond::signal</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Cond::signal</span> &mdash; <span class="dc-title">发送唤醒信号</span></p>   </div>    <div id="cond.signal-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.cond.php" class="classname">Cond</a> 类移除。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-cond.signal-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Cond::signal</strong></span>     ( <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$condition</span>   </span>    )</div>    <p class="para rdfs-comment">     </p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-cond.signal-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">condition</span></dt>      <dd>       <span>通过调用 <span class="function">{@link Cond::create()}</span> 函数获得的条件变量句柄</span>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-cond.signal-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">布尔值，表示操作是否成功。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-cond.signal-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4409">     <p><strong>Example #1 发送唤醒信号</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为&nbsp;Cond&nbsp;不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$cond&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;调用者必须持有关联的互斥量锁，然后才可以进行唤醒信号发送（调用&nbsp;signal&nbsp;方法）&nbsp;&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">signal</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的条件变量&nbsp;*<br /></span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> bool(true) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.cond.php">Cond</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function signal( $condition ) {}

/**
*<div id="cond.wait" class="refentry">  <div class="refnamediv">   <h1 class="refname">Cond::wait</h1>   <p class="verinfo">(PECL pthreads &lt; 3.0.0)</p><p class="refpurpose"><span class="refname">Cond::wait</span> &mdash; <span class="dc-title">等待</span></p>   </div>    <div id="cond.wait-refsynopsisdiv">   <div class="warning"><strong class="warning">Warning</strong>    <p class="para">     pthreads v3 中已经将 <a href="http://php.net/manual/zh/class.cond.php" class="classname">Cond</a> 类移除。    </p>   </div>  </div>   <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 description" id="refsect1-cond.wait-description">   <h3 class="title">说明</h3>   <div class="methodsynopsis dc-description" style="border:1px gray;padding-left:5px;background:#232525">    <span class="modifier">final</span>     <span class="modifier">public</span>     <span class="modifier">static</span>     <span class="type" style="color:#EAB766">bool</span>     <span class="methodname" style="color:#CC7832"><strong>Cond::wait</strong></span>     ( <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$condition</span>    </span>    , <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$mutex</span>    </span>    [, <span class="methodparam">    <span class="type" style="color:#EAB766">int</span>     <span class="parameter" style="color:#2EACF9">$timeout</span>   </span>   ] )</div>    <p class="para rdfs-comment">进入条件变量等待状态。通过 timeout 参数可以设置等待超时时间。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 parameters" id="refsect1-cond.wait-parameters">   <h3 class="title">参数</h3>   <dl>          <dt> <span class="parameter" style="color:#2EACF9">condition</span></dt>      <dd>       <span>通过调用 <span class="function">{@link Cond::create()}</span> 函数获得的条件变量句柄</span>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">mutex</span></dt>      <dd>       <p class="para">通过调用 <span class="function">{@link Mutex::create()}</span> 函数获得的互斥量，并且已经被调用者线程加锁。</p>     </dd>              <dt> <span class="parameter" style="color:#2EACF9">timeout</span></dt>      <dd>       <p class="para">等待超时，以毫秒为单位。</p>     </dd>        </dl>   </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 returnvalues" id="refsect1-cond.wait-returnvalues">   <h3 class="title">返回值</h3>   <p class="para">布尔值，表示操作是否成功。</p>  </div>    <br></br><div style="BORDER-TOP: gray 1px dashed; OVERFLOW: hidden; HEIGHT: 1px"></div><div class="refsect1 examples" id="refsect1-cond.wait-examples">   <h3 class="title">范例</h3>   <span>    <div class="example" id="example-4410">     <p><strong>Example #1 等待条件变量</strong></p>     <div class="example-contents"> <div class="phpcode" style="border-color:gray;background:#232525"><span><span style="color: #000000"> <span style="color: #9876AA">&lt;?php<br /></span><span style="color: #FF8000">//*&nbsp;请注意，本示例会导致进程挂起&nbsp;*<br /></span><span style="color: #9876AA">$mutex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">(</span><span style="color: #9876AA">true</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//*&nbsp;不可以使用&nbsp;new&nbsp;关键字，因为&nbsp;Cond&nbsp;不是&nbsp;PHP&nbsp;对象&nbsp;*<br /></span><span style="color: #9876AA">$cond&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">create</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">//*&nbsp;The&nbsp;caller&nbsp;must&nbsp;lock&nbsp;the&nbsp;associated&nbsp;Mutex&nbsp;before&nbsp;a&nbsp;call&nbsp;to&nbsp;broadcast&nbsp;*<br /></span><span style="color: #9876AA">var_dump</span><span style="color: #007700">(</span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">wait</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">,&nbsp;</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">));<br /></span><span style="color: #FF8000">//*&nbsp;永远不要忘记销毁你创建的条件变量及互斥量&nbsp;*<br /></span><span style="color: #9876AA">Cond</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$cond</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">unlock</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">Mutex</span><span style="color: #007700">::</span><span style="color: #9876AA">destroy</span><span style="color: #007700">(</span><span style="color: #9876AA">$mutex</span><span style="color: #007700">);<br /></span><span style="color: #9876AA">?&gt;</span> </span> </span></div>     </div>      <div class="example-contents"><p>以上例程会输出：</p></div>     <div class="example-contents screen" style="background:black;padding-left:5px;"> <div class="cdata"><span> int(49685473) </span></div>     </div>    </div>   </span>  </div>   <div class="up"><a href="http://php.net/manual/zh/class.cond.php">Cond</a></div></div>
     * @return boolean <p>A boolean indication of success.</p>*/
    final public static function wait( $condition, $mutex, $timeout = 0 ) {}
}
